package ying.cookie02;/**
 * ClassName: GetCookie02
 * Package: ying.cookie02
 * Description:
 *
 * @Author 刘英杰
 * @Create 2024/10/4 22:25
 * @Version 1.0
 */

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import jakarta.servlet.annotation.*;
import ying.utils.CookieUtils;

import java.io.IOException;

@WebServlet("/path01/path02/getCookie02")
public class GetCookie02 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Cookie[] cookies = request.getCookies();
        Cookie cookie = CookieUtils.getCookie(cookies, "gender");
        System.out.println(cookie == null ? "null" : cookie.getValue());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
